package com.cyw.baselibrary.utils;

import com.blankj.utilcode.util.PathUtils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/** 日志助手
 * Created by Administrator on 2019/4/24.
 */

public class LogUtils {

    public static void saveLog(final String content) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                File file = new File(PathUtils.getExternalAppDataPath() +  "/log.txt");
                if (!file.exists()) {
                    try {
                        file.createNewFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                FileOutputStream fileW = null;
                try {
                    fileW = new FileOutputStream(file.getPath(),true);
                    fileW.write("====================".getBytes());
                    fileW.write(content.getBytes());
                    fileW.close();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (fileW != null) {
                        try {
                            fileW.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }

                }

            }
        }).start();
    }

}
